<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //es5: 构造函数+原型对象
        function Dog(name){
            this.name = name
        }
        Dog.prototype.eat =function(){
            console.log(this.name +'坑骨头')
        }
       let dog =new Dog('阿汪')
       dog.eat()
        //es6：类class
        class Animal{
            constructor(age){
                this.age = age
            }
            drink(){
                console.log('drink')
            }
        }
        class Cat extends Animal{
            constructor(name,age){
                super(age)
                this.name = name
            }
            eat(){
                console.log(this.name +'jja')
            }
        }

      const cat = new Cat('xiaohuang',12)
        cat.drink()
  
    </script>
</body>
</html>